package com.gaof.hookactivity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;

public class LoginActivity extends AppCompatActivity {

    private String className;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        className=getIntent().getStringExtra("className");
    }

    public void login(View view) {
        SharedPreferences share=getSharedPreferences("gaof", Context.MODE_PRIVATE);
        share.edit().putBoolean("login",true).apply();
        Toast.makeText(this,"登录成功",Toast.LENGTH_SHORT).show();
        if(!TextUtils.isEmpty(className)){
            try {
                Class<?> jumpClass=Class.forName(className);
                Intent intent=new Intent(this,jumpClass);
                startActivity(intent);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
        finish();
    }
}
